package com.naotebuk.service;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import com.naotebuk.dao.ClienteDAO;
import com.naotebuk.entity.Cliente;

/**
 *
 * @author felpehts
 */
@FacesConverter(value="clienteConverter")
public class ClienteConverter implements Converter {

	 @Override
	 public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
		 Cliente cliente =  ClienteDAO.buscaPorCpf(string);
	
		 return cliente;
	 }

	 @Override
	 public String getAsString(FacesContext fc, UIComponent uic, Object o) {
		 Cliente cliente = new Cliente();
		 cliente = (Cliente) o;
		
		 return cliente.getCpf();
	 }

}
